package net.anzhuo.service.impl;

import net.anzhuo.common.entity.PaginationVO;
import net.anzhuo.dao.GsBranchMapper;
import net.anzhuo.dao.GsCorpothersinfoMapper;
import net.anzhuo.entity.GsBranch;
import net.anzhuo.entity.GsCorpothersinfo;
import net.anzhuo.service.GsBranchService;
import net.anzhuo.service.GsCorpothersinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class GsCorpothersinfoServiceImpl implements GsCorpothersinfoService {

	@Autowired
	private GsCorpothersinfoMapper gsCorpothersinfoMapper;

	@Override
	public PaginationVO<GsCorpothersinfo> getListWithPage(GsCorpothersinfo gsCorpothersinfo) {
		PaginationVO<GsCorpothersinfo> paginationVO = new PaginationVO<>();
		paginationVO.setList(gsCorpothersinfoMapper.getListWithPage(gsCorpothersinfo));
		paginationVO.setTotalCount(gsCorpothersinfoMapper.getCount(gsCorpothersinfo));
		paginationVO.setTotalPage((gsCorpothersinfoMapper.getCount(gsCorpothersinfo) + gsCorpothersinfo.getPageSize() -1)  / gsCorpothersinfo.getPageSize());
		paginationVO.setPageNo(gsCorpothersinfo.getPageNo());
		return paginationVO;
	}

	@Override
	public GsCorpothersinfo getById(Long id) {
		return gsCorpothersinfoMapper.getById(id);
	}

	@Override
	public List<GsCorpothersinfo> getList() {
		return gsCorpothersinfoMapper.getList();
	}

	@Override
	public List<GsCorpothersinfo> getList(GsCorpothersinfo gsCorpothersinfo) {
		return gsCorpothersinfoMapper.getListByQuery(gsCorpothersinfo);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void update(GsCorpothersinfo gsCorpothersinfo) {
		gsCorpothersinfoMapper.update(gsCorpothersinfo);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void save(GsCorpothersinfo gsCorpothersinfo) {
		gsCorpothersinfoMapper.save(gsCorpothersinfo);
	}

	@Override
	@Transactional(rollbackFor=Throwable.class)
	public void delete(GsCorpothersinfo gsCorpothersinfo) {
		gsCorpothersinfoMapper.delete(gsCorpothersinfo);
	}

	@Override
	public List<GsCorpothersinfo> getByMd5(String md5) {
		return gsCorpothersinfoMapper.getByMd5(md5);
	}
}
